# gem install json


require 'json'

data = {
    "name": "John",
    "age": 30,
    "city": "New York"
}

puts JSON.parse(JSON.pretty_generate(data))["name"]





